<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title></title>
    <script src="prompt_css_js\js\popups.js" type="text/javascript" charset="utf-8"></script>
    <link rel="stylesheet" type="text/css" href="prompt_css_js\css\style.css"/>
    <script src="prompt_css_js\js\jquery-2.2.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="js\jquery.js" type="text/javascript" charset="utf-8"></script>
    <style type="text/css">
			.content {
				margin:0 auto;
			    width:100%;
			    height: 30px;
			    margin-top: 20px;

			}
			.showTotal{

				width:100%;
			    height:50px;
			    margin:0 auto;
			    background:#CCCCCC;
			    position:fixed;
			    bottom:50px;
			    text-align:right;
			    font-size: 15px;
			    padding: 15px 10px 0;
                box-sizing: border-box;
			}
			.bottomNavigation {
			    width:100%;
			    height:50px;
			    margin:0px;
			    background:#CCCCCC;
			    position:fixed;
			    bottom:0;
			    text-align:center;
                display: flex;
			}
			input[type=button].button1{
				width:25%;
				height: 100%;
				background: white;
                border: none;
                outline: none;
                box-sizing: border-box;
                border-left: 1px solid #cfcece;
                border-radius: 0;
			}
            .button1:first-child{
                border: none;
            }
			.xiugai input[type=text]{
				width: 15px;
				height: 15px;
				font-size: 14px;
                text-align: center;
                border: none;
                font-weight: bold;

			}
            .xiugai input[type=text]:nth-child(2){
                background-color: #eee;
                width: 25px;
                font-weight: normal;
                font-size: 11px;
            }
			.xiugai input[type=image]{
				width: 20px;
				height: 20px;
				border: 1;
			}
			.shanchu input[type=image]{
				width: 30px;
				height: 30px;
			}
			#myid2{width: 25%;}
			#myid3{width: 15%;}
			#myid4{width: 15%;}
			#myid5{width: 20%;}
			#myid6{width: 10%;}
			.tablebox{
				font-size: 15px;
				width: 100%;
                margin:  0 auto;
                border-collapse: collapse;
			}
			.tablebox th{
				font-size: 15px;
                text-align: center;
                border-bottom: 1px solid #e9e8e8;
                padding: .5em 0;
			}
            .tablebox td{
                border-bottom: 1px solid #e9e8e8;
                padding: 0.3em 0;
                text-align: center;
            }
            #jian{
				width: 15px;
				height: 15px;
			}
			#jia{
				width: 15px;
				height: 15px;
			}
		</style>
    <script type="text/javascript">
			//页面加载时执行
			window.onload=function(){
				show();
			  var tables=document.getElementById('table');
			  var tr=tables.getElementsByTagName('tr');//拿到tr
			  var total=0;//购物车页面用于计算总价
			  for(var i=1;i<tr.length-1;i++){//对每个tr操作
			   fn1(tr[i]);
			  }
			   //页面刷新时，计算总价格
			  var myTotal="共计："+total+"元";
			   document.getElementById('total').innerText=myTotal;

			  function fn1(tr){
			  var name=tr.children[1].innerHTML;//得到商品名称
			   var aStrong=tr.children[4].getElementsByTagName("input");//得到数量  alert(aStrong[0].value);
			   var aEm=tr.children[3].innerHTML;//得到单价
			   var num=aStrong[1].value; //aStrong.innerHTML='0'
			   var price=parseFloat(aEm);//aEm.innerHTML='12.9元'
			   total+=num*price;
			   aStrong[0].onclick=function(){
			   if(num>0){
			   num--;
			   //修改购物车
			   addToCart( name, num, price);
			   //页面静态更改
			   aStrong[1].value=num;
			   tr.children[2].innerText=num;
			   //判断复选框是否是选中状态，是的话加入共计里面
			   	var showTotal=document.getElementById('total').innerText;//得到要变化的总价
			   var subShowTotal=showTotal.substring(3);//截取字符串
			   var myTotal=parseInt(subShowTotal);
			   	myTotal=myTotal-price;
			   	document.getElementById('total').innerHTML='共计: '+myTotal+'元'
			   }
			   }
			   aStrong[2].onclick=function(){
			   num++;
			   //修改购物车
			   addToCart( name, num, price);
			   //页面静态更改
			   aStrong[1].value=num;
			   tr.children[2].innerText=num;
			   	var showTotal=document.getElementById('total').innerText;//得到要变化的总价
			   var subShowTotal=showTotal.substring(3);//截取字符串
			   var myTotal=parseInt(subShowTotal);
			   myTotal=myTotal+price;
			   	document.getElementById('total').innerHTML='共计: '+myTotal+'元'
			   }
			  }

			}
			function show(){
			var results=myjson();//区分从历史订单过来的json、还是从购物车过来的json
			var json=results[0];
			var toActivity=results[1];
				if(toActivity=="toShoppingCart"){//从购物车过来的json
				    var	str= "<tr>" +
						//"<th>" + "" + "</th>" +
                        "<th>" + "名称" + "</th>" +
                        "<th>" + "数量" + "</th>" +
                        "<th>" + "价格" + "</th>" +
                        "<th>" + "修改" + "</th>" +
                        "<th>" + "删除" + "</th>" +
                        "</tr>";
        	    for(var key in json){
                     str += "<tr>" +
                        //"<td id='myid1'>" + "" + "</td>" +
                     	"<td id='myid2'>" + json[key].name + "</td>" +
                     	"<td id='myid3'>" + json[key].number + "</td>" +
                     	"<td id='myid4'>" + json[key].price + "</td>" +
                     	"<td id='myid5' class='xiugai'>" +
                     	"<input type='text' name='' id='' value='-' readOnly='true'/>"+
                        "<input type='text' name='' id='myNum' value='"+json[key].number+"' readOnly='true'/>"+
                        "<input type='text' name='' id='' value='+' readOnly='true'/>" +
                        "</td>" +
                        "<td id='myid6' class='shanchu'>" + "<input type='image' name='' id='shanchu' value='' src='icon/shanchu.png' onclick='deleteRow(this)'/>" + "</td>" +
                        "</tr>";
        	    }
                        str += "<tr height='100px''>" +
                                //"<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "</tr>";
                         document.getElementById('table').innerHTML=str;
                         return false;
				}else if(toActivity=="toHistoryOrder"){//从历史订单过来的json
				    var	str= "<tr>" +
						//"<th>" + "" + "</th>" +
                        "<th>" + "名称" + "</th>" +
                        "<th>" + "数量" + "</th>" +
                        "<th>" + "价格" + "</th>" +
                        "<th>" + "修改" + "</th>" +
                        "<th>" + "删除" + "</th>" +
                        "</tr>";
        	    for(var key in json){
                     str += "<tr>" +
                        //"<td id='myid1'>" + "" + "</td>" +
                     	"<td id='myid2'>" + json[key].goods_name + "</td>" +
                     	"<td id='myid3'>" + json[key].goods_amount + "</td>" +
                     	"<td id='myid4'>" + json[key].goods_price + "</td>" +
                     	"<td id='myid5' class='xiugai'>" +
                     	"<input type='text' name='' id='' value='-' readOnly='true'/>"+
                        "<input type='text' name='' id='myNum' value='"+json[key].goods_amount+"' readOnly='true'/>"+
                        "<input type='text' name='' id='' value='+' readOnly='true'/>" +
                        "</td>" +
                        "<td id='myid6' class='shanchu'>" + "<input type='image' name='' id='shanchu' value='' src='icon/shanchu.png' onclick='deleteRow(this)'/>" + "</td>" +
                        "</tr>";
        	    }
                        str += "<tr height='100px''>" +
                                //"<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "<td>" + "" + "</td>" +
                                "</tr>";
                         document.getElementById('table').innerHTML=str;
                         return false;

				}
			}
			function toActivity(activityName){
			var remarks="";
			    if(activityName == "ProductListActivity"){
			        //获取到页面输入的备注
                 jqalert({
                            title:'取消订单',
                            prompt:'取消订单的原因?',
                            yestext:'确定',
                            notext:'取消',
                            yesfn:function () {
                                shoppingCart.toActivity(activityName,myText());
                            },
                            nofn:function () {
                                return false;

                            }
                        })

			    }else if(activityName =="DetailsOfSettlementActivity"||activityName=="VerifyingPaymentActivity"){//直接支付

			        //判断table中有没有数据，如果没有 return false;
			        if($("#table").find("tr").length>2){
			         var myCreatDate=historyCreatDate();//调用该方法判断有没有拿到创建时间，带参数传给后台；后台根据值判断是添加或修改订单。
			            //alert("我是shopping中的历史创建时间"+myCreatDate);
			            shoppingCart.toActivity(activityName,myCreatDate);
			        }else{
			            alert("您的购物车为空！暂时不能支付。");
			            return false;
			        }
			    }else{
			        shoppingCart.toActivity(activityName,remarks);
			    }


			}
			function myjson(){
			    var historyOrder=shoppingCart.myIntent();//从历史订单过来的json字符串
			    //alert("历史订单"+historyOrder);
                    if(historyOrder !=""&&historyOrder!=null){
                        json=eval(historyOrder);
                       //alert("shoppingCart.myIntent()！=空串"+historyOrder);
                       var toActivity="toHistoryOrder";
                       var results=new Array(json,toActivity);
                         return results;

                    }else{
                        var json=shoppingCart.show();
                        //alert("购物车"+json);
                        json=eval(json);//全局变量
                        //alert("shoppingCart.myIntent()==空串"+historyOrder);
                        var toActivity="toShoppingCart";
                        var results=new Array(json,toActivity);
                        return results;
                    }

			}

             <!--添加购物车-->
            function addToCart( name, number, price){
              var result=shoppingCart.addToCart(name, number, price);
              alert(result);
            }
             function shanchu(name){
              var result=shoppingCart.deleteItems(name);
             }
			function deleteRow(r){
			    var name=r.parentNode.parentNode.children[1].innerHTML;//得到商品名称
			   if( confirm("是否删除")){

			        shanchu(name);
                    var showTotal=document.getElementById('total').innerText;
                    var subShowTotal=showTotal.substring(3);
                    //算出当前行的总价
                    var shuliang=r.parentNode.parentNode.children[4].children[1].value;
                    var price=r.parentNode.parentNode.children[3].innerText;
                    var myPrice=parseInt(price);
                    //总价减去该行的价格
                    showTotal='共计:'+(parseInt(subShowTotal)-shuliang*myPrice)+'元';
                    document.getElementById('total').innerHTML=showTotal;
                    var i=r.parentNode.parentNode.rowIndex;
                    document.getElementById('table').deleteRow(i);
			   }else{
                    return false;
			   }

			}
			//直接支付时调用该方法，拿到创建时间
			function historyCreatDate(){
               var historyCreatDate=shoppingCart.historyCreatDate();
               return historyCreatDate;
			}
			//继续添加商品到本订单
            function goOn(){
                alert("正在做此功能");
                //如果本页面有订单id，就根据订单id查询出商品，显示数量在商品列表页面。如果没有订单id，直接返回到商品列表页面。
                shoppingCart.goOnAddGoods();
            }

		</script>
    <link rel="stylesheet" href="css/mui.min.css">
</head>
<body style="margin: 0;">
<header id="header" class="mui-bar mui-bar-nav">
    <h1 class="mui-title">其他信息</h1>
</header>
<div id="" hidden="hidden" >
    <input type="text" name="myHidden" id="myHidden" value="" />
</div>

<div id="list" class="content" style="text-align: left;">
    <table id="table" border="0" cellspacing="4" cellpadding="4" class="tablebox" align="center">

    </table>

</div>


<div class="showTotal" id="showTotal">
    <span id="" style="float: left;margin-left: 5px;">
		<a href="javascript:void(0);" onclick="toActivity('HistoryOrderActivity')" style="text-decoration:none;color: lightseagreen;">查询未完成订单</a>
	</span>
    <span id="total">
		  共计: 0元
	</span>
</div>
<div class="bottomNavigation">
    <input type="button"class="button1" onclick="goOn()" value="继续添加" />
    <input type="button"class="button1" onclick="toActivity('ProductListActivity')" value="取消订单" />
    <input type="button"class="button1" onclick="toActivity('DetailsOfSettlementActivity')" value="直接支付" />
    <input type="button"class="button1" onclick="toActivity('VerifyingPaymentActivity')" value="验证支付" />
</div>

</body>
</html>